package com.equipment;

import com.util.EncodingUtil;

/**
 * ESAM还原
 *
 * @author liuyadong
 *
 */
public class ESAMReductionRequest {

	private String STX = "55AA"; // 帧开始标志
	private String RSCTL = "00"; // 串口帧序列号
	private String Length = ""; // 数据长度
	private String code = "FD"; // 代码
	private String broadening = "C7"; // 扩展代码

	private String BCC = ""; // 异或校验值
	/**
	 * 拼接C7指令
	 * @return
	 */
	public String command() {
		// 计算长度
		Length = EncodingUtil.desToHex((broadening).length() / 2, 4);
		// 异或校验从RSCTL到DATA所有字节的异或值
		String DATA = RSCTL + Length + code + broadening;
		// 异或校验从RSCTL到DATA所有字节的异或值
		BCC = EncodingUtil.yihuo(EncodingUtil.change(DATA));
		// 拼接完整的请求
		String retn = STX + DATA + BCC;
		return retn;
	}
}
